@section('title')
与<?php echo $data['user']['realname'] ?>的对话 @parent
@show
@section('content')
<div class="navbar theme-white">
    <div class="navbar-inner">
        <div class="left"><a href="{{ route('letter.users') }}" class="external link icon-only"> <i class="icon icon-back"></i></a></div>
        <div class="center sliding">与<?php echo $data['user']['realname'] ?>的对话</div>
        <div class="right">
            <a class="station-letter-popup link icon-only" href="#{{ route('letter.send', $data['user']['id']) }}"><i class="icon icon-write"></i></a>
        </div>
    </div>
</div>

<div class="pages navbar-through toolbar-fixed">
    <div data-page="letter-user-letters" class="page page-on-center pb60">
        <div class="page-content messages-content">
            <div class="messages">
                <?php foreach($data['grouped_letters'] as $date => $letters): ?>
                    <div class="messages-date"><?php echo $date; ?></div>
                    <?php foreach($letters as $letter): ?>

                        <?php if ($letter['creator_id'] == $data['user']['id']): ?>
                            <div class="message message-with-avatar message-received">
                                <!-- Sender name -->
                                <div class="message-name"><?php echo $data['user']['realname']; ?></div>
                                <!-- Bubble with text -->
                                <div class="message-text"><?php echo $letter['message']; ?></div>
                                <!-- Sender avatar -->
                                <div style="background-image:url('<?php echo $data['user']['avatar'] ? Config::get('app.url').'/'.$data['user']['avatar'] : '/img/1.png'; ?>')" class="message-avatar"></div>
                            </div>
                        <?php else: ?>
                            <div class="message message-sent">
                                <div class="message-text">
                                    <?php echo $letter['message']; ?>
                                </div>
                            </div>
                        <?php endif; ?>
                    <?php endforeach; ?>
                <?php endforeach; ?>
            </div>
        </div>
        @include('widgets.toolbar', array('active'=>'center'))
    </div>
</div>
@stop